<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据绑定</title>
    <script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
            $("#a1").click(function(){
                $("#a1").data("id","2");
                $("#a1").data("name","admin");
            });
            $("#a2").click(function(){
               console.log($("#a1").data("id"));
               console.log($("#a1").data("name"));
            });
            $("#a3").click(function(){
               $("#a1").removeData("id");
            });
        });
    </script>
</head>
<body>
<a id="a1" href="javascript:;">绑定数据</a>
<a id="a2" href="javascript:;">获取数据</a>
<a id="a3" href="javascript:;">删除数据</a>
</body>
</html>